package com.viettel.pon.httpclient;

import org.apache.http.Header;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.loopj.android.http.AsyncHttpResponseHandler;

public class MyJsonHttpResponseHandler extends AsyncHttpResponseHandler{
     public void onFailure(int statusCode, Throwable error, String content) {
             onFailure(statusCode, error);
             onFailure(error);
     }

     public void onFailure(Throwable error) {}
     
     public void onFailure(int statusCode, Throwable error) {}
     
     public void onSuccess(int statusCode, String content) {
             JSONObject response = new JSONObject();
             JSONArray response2 = new JSONArray();
             try {
                     response = new JSONObject(content);
             } catch (Exception e) {
                     try {
                             response.put("success", 0);
                             response.put("errorMessage", String.valueOf(content));
                     } catch (JSONException e1) {
                             e1.printStackTrace();
                     }
             }
             try {
                     response2 = new JSONArray(content);
             } catch (Exception e) {
                     
             }
             onSuccess(statusCode, response2);
             onSuccess(statusCode, response);
             onSuccess(response2);
             onSuccess(response);
     }

     public void onSuccess(JSONObject re) {
             
     }
     
     public void onSuccess(JSONArray re) {
             
     }
     
     public void onSuccess(int statusCode, JSONObject re) {
             
     }
     
     public void onSuccess(int statusCode, JSONArray re) {
             
     }

	@Override
	public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void onSuccess(int arg0, Header[] arg1, byte[] arg2) {
		// TODO Auto-generated method stub
		
	}
}
